package com.wangxiang.shop.product.service.impl;

import com.wangxiang.shop.product.dao.ShopTwoTypeDao;
import com.wangxiang.shop.product.entity.ShopTwoTypeEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wangxiang.common.utils.PageUtils;
import com.wangxiang.common.utils.Query;

import com.wangxiang.shop.product.dao.ShopBaseDao;
import com.wangxiang.shop.product.entity.ShopBaseEntity;
import com.wangxiang.shop.product.service.ShopBaseService;


@Service("shopBaseService")
public class ShopBaseServiceImpl extends ServiceImpl<ShopBaseDao, ShopBaseEntity> implements ShopBaseService {
    @Autowired
    private ShopBaseDao shopBaseDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ShopBaseEntity> page = this.page(
                new Query<ShopBaseEntity>().getPage(params),
                new QueryWrapper<ShopBaseEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public boolean add(String name) {
        ShopBaseEntity shopBaseEntity = new ShopBaseEntity();
        shopBaseEntity.setName(name);
        //查找是否已经存在
        List<ShopBaseEntity> shopBaseEntities = shopBaseDao.selectList(null);
        if (shopBaseEntities!=null){
            String str = shopBaseEntities.toString();
            boolean contains = str.contains(name);
            if (contains){
                return false;
            }else {
                int insert = shopBaseDao.insert(shopBaseEntity);
                if (insert>0) {
                    return true;
                }
            }
        }
        ;
        return false;
    }

    @Override
    public boolean getEntity(List<Integer> list) {
        //查询是否存在

        return false;
    }


}